use std::thread;
use std::time::Duration;
use std::sync::mpsc;

fn main() {
    println!("Hello, world!");

    let (tx, rx) = mpsc::channel();
    for i in 0..100{
        tx.send(move || {
            println!("执行任务 {}", i);
        }).unwrap();
    }

    for k in 0..10{
        let handle = thread::spawn(move || {
            let received = rx.recv().unwrap();

            received();

            // match received{
            //     Ok(func) =>{
            //         func();
            //     },
            //     Err(e) =>{
            //         println!("Error : {:?}", e);
            //     }
            // }
        });

        handle.join().unwrap();
    }
}


